﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Hsmp.SocietyOperation.Entity;
using Hsmp.SocietyOperation.DataAccess;
using Hsmp.SocietyOperation.IBusinessLogic;

using Hsmp.SocietyAdmin.Entity;
using Hsmp.SocietyAdmin.DataAccess;
using Hsmp.SocietyAdmin.IBusinessLogic;

using Ivy.UserRegistration.Entity;
using Ivy.UserRegistration.DataAccess;
using Ivy.UserRegistration.IBusinessLogic;


namespace Hsmp.SocietyOperation.BusinessLogic
{
    public class SocietyManagementCommitteeRegistrationBus : ISocietyManagementCommitteeRegistrationBus
    {
        #region  Variable & constant
        #endregion  Variable & constant

        #region Constructor & Destructor
        #endregion Constructor & Destructor

        #region Properties
        #endregion Properties

        #region Public Methods
        #region ISocietyManagementCommitteeRegistrationBus Members
        public bool AddSocietyManagementCommitteeMember(SocietyManagementMemberRegister SocietyManagementMemberRegisterEntity)
        {
            bool IsOperationSuccessful = false;
            try
            {
                SocietyManagementMemberRegisterDao lSocietyManagementMemberRegisterDao = new SocietyManagementMemberRegisterDao();
                IsOperationSuccessful = lSocietyManagementMemberRegisterDao.Insert(SocietyManagementMemberRegisterEntity);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            }
            return IsOperationSuccessful;
        }

        public bool UpdateRegisteredSocietyManagementCommitteeMember(SocietyManagementMemberRegister SocietyManagementMemberRegisterEntity)
        {
            bool IsOperationSuccessful = false;
            try
            {
                SocietyManagementMemberRegisterDao lSocietyManagementMemberRegisterDao = new SocietyManagementMemberRegisterDao();
                IsOperationSuccessful = lSocietyManagementMemberRegisterDao.Update(SocietyManagementMemberRegisterEntity);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            }
            return IsOperationSuccessful;
        }

        public SocietyManagementMemberRegister GetSelectedSocietyManagementCommitteeMemberDetails(int SocietyKey, int UserKey)
        {
            try
            {
                SocietyManagementMemberRegisterDao lSocietyManagementMemberRegisterDao = new SocietyManagementMemberRegisterDao();
                SocietyManagementMemberRegister lSocietyManagementMemberRegister;
                lSocietyManagementMemberRegister = lSocietyManagementMemberRegisterDao.GetManagementMemberBySocietyKeyAndUserKey(SocietyKey, UserKey);
                if (lSocietyManagementMemberRegister == null)
                {
                    return null;
                }
                else
                {
                    return lSocietyManagementMemberRegister;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            }
        }

        public List<SocietyManagementMemberRegister> GetAllSocietyManagementCommitteeMemberForSelectedSociety(int SocietyKey)
        {
            List<SocietyManagementMemberRegister> lSocietyManagementMemberRegister = new List<SocietyManagementMemberRegister>();
            try
            {
                SocietyManagementMemberRegisterDao lSocietyManagementMemberRegisterDao = new SocietyManagementMemberRegisterDao();
                lSocietyManagementMemberRegister = lSocietyManagementMemberRegisterDao.GetManagementMembersBySocietyKey(SocietyKey);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            }
            return lSocietyManagementMemberRegister;
        }

        //public SocietyManagementMemberRegister GetSelectedSocietyManagementCommitteeMemberByID(string UserKey)
        //{
        //    try
        //    {
        //        SocietyManagementMemberRegisterDao lSocietyManagementMemberRegisterDao = new SocietyManagementMemberRegisterDao();
        //        SocietyManagementMemberRegister lSocietyManagementMemberRegister;
        //        lSocietyManagementMemberRegister = lSocietyManagementMemberRegisterDao.GetByID(UserKey);
        //        if (lSocietyManagementMemberRegister == null)
        //        {
        //            return null;
        //        }
        //        else
        //        {
        //            return lSocietyManagementMemberRegister;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        System.Diagnostics.Debug.Print(ex.Message);
        //        throw ex;
        //    }
        //}

        //public List<SocietyManagementMemberRegister> GetAllSocietyManagementCommitteeMember()
        //{
        //    List<SocietyManagementMemberRegister> lSocietyManagementMemberRegisterList = new List<SocietyManagementMemberRegister>();
        //    try
        //    {
        //        SocietyManagementMemberRegisterDao ISocietyManagementMemberRegisterDao = new SocietyManagementMemberRegisterDao();
        //        lSocietyManagementMemberRegisterList = ISocietyManagementMemberRegisterDao.GetAll();
        //    }
        //    catch (Exception ex)
        //    {
        //        System.Diagnostics.Debug.Print(ex.Message);
        //        throw ex;
        //    }
        //    return lSocietyManagementMemberRegisterList;
        //}

        public User GetSelectedUser(int UserKey)
        {
            try
            {
                UserDao lUserDao = new UserDao();
                User lUser = lUserDao.GetByID(UserKey.ToString());

                if (lUser == null)
                {
                    return null;
                }
                else
                {
                    return lUser;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            }
        }

        public UserProfile GetSelectedUserProfile(int UserKey)
        {
            try
            {
                UserProfileDao lUserProfileDao = new UserProfileDao();
                UserProfile lUserProfile = lUserProfileDao.GetByID(UserKey.ToString());

                if (lUserProfile == null)
                {
                    return null;
                }
                else
                {
                    return lUserProfile;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            }
        }

        public Society GetSelectedSociety(int SocietyKey)
        {
            try
            {
                SocietyDao lSocietyDao = new SocietyDao();
                Society lSociety = lSocietyDao.GetByID(SocietyKey.ToString());

                if (lSociety == null)
                {
                    return null;
                }
                else
                {
                    return lSociety;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            }
        }

        public List<User> GetAllUserForSelectedSociety(int SocietyKey)
        {
            throw new NotSupportedException();
        }

        #endregion
        #endregion Public Methods

        #region Events
        #endregion Events

        #region Private Methods
        #endregion Private Methods

    }
}
